namespace FormsAnywhere.UIProcessDesigner
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Collections.Specialized;
    using Microsoft.VisualStudio.Modeling.Validation;

    [ValidationState(ValidationState.Enabled)]
    public partial class FormResource
    {
        // Validation methods for FormResource go here.

        // This attribute identifies the method ValidateNameValue 
        // to the validation framework.
        [ValidationMethod
         ( // These values select which events cause the method to be invoked.
            ValidationCategories.Open |
             ValidationCategories.Save |
              ValidationCategories.Menu
         )
        ]
        // This method is applied to each instance of the 
        // type in a model. 
        private void ValidateNameValue(ValidationContext context)
        {
            if (this.Name.Length <= 0)
            {
                context.LogError(
                    // Description
                             "A value is required for the element Name",
                    // Unique code for this error
                             "FAW001FormResourceError",
                    // Objects to select when user double-clicks error
                             this);
            }
        }

        // This attribute identifies the method ValidateTitleValue 
        // to the validation framework.
        [ValidationMethod
         ( // These values select which events cause the method to be invoked.
             ValidationCategories.Open |
             ValidationCategories.Save |
              ValidationCategories.Menu
         )
        ]
        // This method is applied to each instance of the 
        // type in a model. 
        private void ValidateTitleValue(ValidationContext context)
        {
            if (this.Title.Length <= 0)
            {
                context.LogError(
                    // Description
                             "A value is required for the element Title",
                    // Unique code for this error
                             "FAW002FormResourceError",
                    // Objects to select when user double-clicks error
                             this);
            }
        }

        // This attribute identifies the method ValidatePromptValue 
        // to the validation framework.
        [ValidationMethod
         ( // These values select which events cause the method to be invoked.
             ValidationCategories.Open |
             ValidationCategories.Save |
              ValidationCategories.Menu
         )
        ]
        // This method is applied to each instance of the 
        // type in a model. 
        private void ValidatePromptValue(ValidationContext context)
        {
            if (this.Prompt.Length <= 0)
            {
                context.LogError(
                    // Description
                             "A value is required for the element Prompt",
                    // Unique code for this error
                             "FAW003FormResourceError",
                    // Objects to select when user double-clicks error
                             this);
            }
        }

    }
}
